(() => {
  class Animal {
    name: string;

    constructor(name: string) {
      this.name = name;
  
    }
    sayHello() {
      console.log(`${this.name}sayHello`);
    }
  }

  class Dog extends Animal {
    age: number;
    constructor(name: string, age: number) { 
      super(name);//必须先调用父类的构造函数
      age = this.age;
    }

    sayHello(): void {
      super.sayHello(); //super表示当前类的父类
    }
  }

  const dog = new Dog('旺财',1);
  dog.sayHello();
})();
